/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.irssproject.app.entitats.recommendations;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 *
 * @author adria
 */
@Entity
@Table(name = "topics_subscription")
public class TopicSubscription implements Serializable {

    private static final long serialVersionUID = 1L;
    protected TopicSubscriptionPK topicSubscriptionPK;

    public TopicSubscription() {
    }

    public TopicSubscription(TopicSubscriptionPK topicSubscriptionPK) {
        this.topicSubscriptionPK = topicSubscriptionPK;
    }

    @EmbeddedId
    public TopicSubscriptionPK getTopicSubscriptionPK() {
        return topicSubscriptionPK;
    }

    public void setTopicSubscriptionPK(TopicSubscriptionPK topicSubscriptionPK) {
        this.topicSubscriptionPK = topicSubscriptionPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (topicSubscriptionPK != null ? topicSubscriptionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TopicSubscription)) {
            return false;
        }
        TopicSubscription other = (TopicSubscription) object;
        if ((this.topicSubscriptionPK == null && other.topicSubscriptionPK != null) || (this.topicSubscriptionPK != null && !this.topicSubscriptionPK.equals(other.topicSubscriptionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "[ user: " + topicSubscriptionPK.getIdUser() + ", topic subscribed: " + topicSubscriptionPK.getIdTopic_subscribed() + " ]";
    }
}
